Charles Builds Stuff


2018-03-01 Remote controlled tank, part 1: Designing a big motor controller.

"You know what would be cool," I rhetorically asked a friend, "a remote control tank that has some serious heft to it. Like, some really serious heft.

"How about large enough to sit on and get carried by?"

"Sounds perfect".


And with that inspiration, I was off to the races. My sights settled on the 1kW (1.3 HP) power range for it being easy enough to achieve and sufficiently exciting to be worthwhile. This being a tank, I decided to go with four wheel skid-steer to simplify the mechanical design a bit, with my intention being that, at 1kW in a less-than 20 kilogram vehicle, any wheel slippage could be made up for be applying more speed.

A quick search of Ebay and the like revealed that a pair of 500W brushed DC motors would get me the most bang for my buck. I already suspected this from my (regrettably undocumented) electric go-kart capers of years past. But, now, with access to all the tools of Waterloo Engineering at my disposal, I could do it correctly.

As a matter of cost and convenience, a 24 volt motor was selected (specifically, the MY1020 from Unite Motor). This draws 27 amps at full power, and the final vehicle will have two of them. This leads to the selection of a battery (liPo, 6S, >60A discharge rate, and preferably enough capacity to keep the machine operating at full throttle for half an hour), and an electronic speed controller (ESC).


Would you believe that nobody has a reasonably priced dual-channel, reversible, active-braking, 500W, 24V ESC available for sale?

This is where the fun began

Clearly, the reasonable and most educational choice would be to design my own ESC. So I did.

A motor controller, at its heart, is a bunch of switches (generally MOSFETs or IGBTs) connected to something that allows them to be turned on and off very quickly and exceptionally carefully. For reversibility and active-braking of a brushed DC motor, an H-bridge configuration is usually (read: almost without exception) your best bet.

Eight MOSFETs and a microncontroller sounds awfully straightforward when phrased that way. However, as the coilgun adventure proved last year, high power, high precision switching is... difficult, and best left to the professionals.

Enter the DRV-8704 dual-channel H-bridge controller from TI. It handles all the tricky bits, like switching the MOSFETs and watching for overcurrent events, and allows one to control it with four logic lines. If it sounds like black magic, that's because it pretty much is.

After reading the datasheet once over and finding a reference implementation, it was off to Eagle!


Where, much to nobody's but my surprise, the HTSSOP-38 "PowerPad" package did not exist. Nor, subsequently, did the DRV8704. So I learned to make custom parts in Eagle by following this somewhat outdated but still very useful tutorial from SparkFun.


Look mom, I did it!

Within a day, I had the guts of the circuit figured out from the datasheet and reference implementation - MOSFETs on one side, decoupling and charge-pump capacitors on the other, and frightening current sense resistors packed into the ground lines for the motor. But an H-bridge does not an ESC make. Some device to actually control the controller was needed.

As a shameless Arduino fanboy, I opted for an ATMega328p, of Arduino Uno fame. It is available as a DIP package, readily programmmed with the tools I have on hand, and, in the event of emergency landing on the rocks of despair and complicated embedded C++, can be flashed with the Arduino bootloader to allow me to retreat with my tail between my legs to a safe place. Also to write code quickly.

An ATMega328p has a UART, but no USB capabilities. I went with an FTDI FT232RL, which needs no introduction. The three main chips required a large amount of glue components, including a switching regulator module.

The whole schematic, with FT232RL, Atmega328p, and DRV8704

That'll work

The ATMega part of the schematic was based off of the Arduino Deumilanove, and clocked at a conservative 16 MHz so that I could flash it with the Arduino Uno's booloader without needing to fiddle about with any configuration files.

About those MOSFETs

There are a lot of N-channel power MOSFETs on the market. Hell, there are a lot of them on DigiKey. So how did I chose the IRLB8314PBFs that I did?

The large criteria are continuous current capability, (Vds)max, (Rds)on, (Vgs)max, and the diode characteristics (i.e, it needs to have a body diode). The maximum current per device is 171 A, which provides a degree of overhead - recall that 27 amps of capacity are needed. Why, then, are there two of them in parallel?

In short, overkill and a poor design choice made before having selected the MOSFETs properly.

On each channel of the driver, there are four pairs of MOSFETs. At full gate charge, each transistor has a resistance of 2.4 milliohms. With 15 amps going through each transistor, a fairly sedate 1.08 watts of power is dissipated from each pair. All things considered, that's totally fine. Given that these are 500W motors, that's a efficiency of 99%, which is certainly good enough!


So why the hell does my design have provisions for paired transistors with 10W of heatsinking, and several inches of unnecessary copper between the switches and the motors?

Well, the answer is simple: I screwed up. With better design, I could have saved board space ($), power consumption, BOM cost ($), and heat. The board traces will be dissipating 10W, yikes, and reaching 70°C at 20°C ambient. Yikes.

This puts a dent in the wonderful efficiency numbers. In the second revision, the board will likely be half the size, and subsequently won't need the fan mounts or power supply, saving board and BOM. Also, I'll ensure the holes are all the right sizes.

The holes are what now?

I had to make several unique Eagle components for this. I did not get all of them entirely correct. The hole spacing was perfect in all cases (much to my relief), but the hole sizing on the 65A and 30A screw terminals left a bit to be desired. The battery connector was insertable, albeit barely, and the motor connectors could not be inserted except with a hammer.

Too late, boards are already on order for a week.

And, with any luck, they'll work

Tune in next time!